package com.lai.note.fragment;

import android.os.Bundle;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.lai.note.R;
import com.lai.note.adapter.NoteRecyclerAdapter;
import com.lai.note.model.Note;
import com.lai.note.util.ListNoteUtil;

import java.util.ArrayList;
import java.util.List;


public class RecordsNoteFragment extends Fragment {
    public RecordsNoteFragment(){
        super(R.layout.listnote_recyclerview);
    }

    private RecyclerView recyclerView;
    private NoteRecyclerAdapter adapter;
    private LinearLayoutManager layoutManager;
    private List<Note> notes = new ArrayList<Note>();

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initViews();
        initData();
    }

    private void initViews(){
        recyclerView = getView().findViewById(R.id.note_recyclerview);
        adapter = new NoteRecyclerAdapter(notes);
        layoutManager = new LinearLayoutManager(getActivity());
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.setAdapter(adapter);
    }

    private void initData(){
        ListNoteUtil.initDatas(getContext(),adapter);
    }










}
